/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package general;

/**
 * Padrão Build
 * @author foliveira
 */
public class RequestBuilder {
  private Request request;
  private String data;

    public RequestBuilder() {
        request = new Request();
    }
  
  
  
  public RequestBuilder(String data) {
    this.data = data;
    request = new Request();
    build(); // cria o objeto    
  }
  
  private void build(){
    
    String[] pieces=null;
    
    try {
      
      pieces = data.split(":");
      
    } catch (Exception e) {
      System.err.println("erro ao criar o objeto Request");  
    }
    
    request.setAgent(pieces[0]);
    request.setCommand(pieces[1]);
    request.setData(pieces[2]);
    request.setUser(pieces[3]);
    request.setPasswd(pieces[4]);
    request.setMessageReturn(pieces[5]);
    
  }

  public Request getRequest() {
    return request;
  }    

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
  
  
  
}
